package com.beifu.manager.filter;

import com.utils.ResponseHelp;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by 再壮 on 2018/7/23.
 */
@ResponseBody
@ControllerAdvice
public class ExceptionHandlerAdvice {

    private Logger log = Logger.getLogger(this.getClass());

    /**
     * 拦截所有异常信息。
     * @param exception
     * @return
     */
    @ExceptionHandler(value = Exception.class)
    public String exception(Exception exception) {

        exception.printStackTrace();

        return ResponseHelp.responseApiErrorText("999999", exception.toString());
    }

}
